//
//  CTVChannelsNet.h
//  Channltv
//
//  Created by Bruno Keymolen on 03/09/07.
//  Copyright 2007 channl.tv. All rights reserved.
// 
//  downloads the data xml's to the cache /Data/ slot (overwrite if exist)
//

#import <Cocoa/Cocoa.h>


@class CTVDataDownloadReply, CTVHTTPDataDownload;

@protocol CTVDataDownloadReply
	-(int)finishDataDownload:(CTVHTTPDataDownload*)dataDownload;
	-(int)releaseDataDownload:(CTVHTTPDataDownload*)dataDownload;
@end


@interface CTVHTTPDataDownload : NSObject {
	CTVDataDownloadReply* m_dataReply;
	NSString* m_url;
	NSString* m_cachePath;
	NSURLConnection* m_connection;	
	NSMutableData* m_data;
	int m_httpStatusCode;
}

-(id)initWithURLString:(NSString*)urlstring andDataReply:(CTVDataDownloadReply*)dataReply;
-(void)dealloc;
-(int)cache;
-(NSString*)cachePath;
-(NSString*)urlString;
-(int)httpStatusCode;

/* NSURLConnection Delegates */
- (void)connection:(NSURLConnection *)connection didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse;
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse;
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;

@end
